package com.java.simple.study.juc.pattern;

import java.io.Serializable;

/**
 * @author zhoujunlin
 * @date 2022年06月07日 17:19
 * @desc 单例模式
 */
public final class Singleton5 implements Serializable {

    private Singleton5() {
    }

    private static class SingletonHolder {
        static final Singleton5 singleton = new Singleton5();
    }

    /**
     * @return
     */
    public Singleton5 getInstance() {
        return SingletonHolder.singleton;
    }

    /**
     * 解决反序列化问题
     *
     * @return
     */
    public Object readResolve() {
        return getInstance();
    }
}
